package org.jianghu.base;

import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Gtexpress on 16/12/9.
 * Fragment基类
 */

public abstract class BaseFragment extends Fragment{

    protected FragmentActivity mActivity;

    /**
     * 根view
     */ protected View mRootView;


    /**
     * 是否对用户可见
     */ protected boolean mIsVisible;


    /**
     * 是否加载完成
     * 当执行完oncreatview,View的初始化方法后方法后即为true
     */ protected boolean mIsPrepare;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        mActivity = (FragmentActivity) getActivity();

    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        mRootView = inflater.inflate(setLayoutResouceId(),container,false);

        return mRootView;
    }

    /**
     * 设置根布局资源id
     *
     * @return
     */ protected abstract int setLayoutResouceId();

}
